package com.syg.case05;

import org.springframework.aop.support.AopUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

@RestController
public class ControllerCase05 {


    @Resource
    ACase05 acase05;

    /**
     * 情况5：B类被AOP增强,在同一个方法中执行B类中两个不同的方法
     * 方法2会被拦截,AOP执行两次
     */
    @RequestMapping(value = "/case05",method = RequestMethod.GET)
    public void proxyClassTest(){
        // aopProxy1结果是true 此时是通过AOP增强的对象,因为切入点配置到了类
        boolean aopProxy1 = AopUtils.isAopProxy(acase05);
        System.out.println("proxyClassTest result = " + aopProxy1);
        System.out.println("spring ioc=" + acase05.hashCode() + ",地址值=" + this);
        acase05.save01();
        acase05.save02();
    }
}
